//
//  SquareHeadrerView.m
//  Findif
//
//  Created by Mac on 2019/2/11.
//  Copyright © 2019年 Cicel Chen. All rights reserved.
//

#import "SquareHeadrerView.h"

@interface SquareHeadrerView ()

@property (nonatomic, weak)UIView * backView;
@property (nonatomic, weak)UIView * redView;
@property (nonatomic, weak)UILabel * titleLabel;
@property (nonatomic, weak)UIView * lineView;

@end

@implementation SquareHeadrerView


- (void)setString:(NSString *)string{
    
    _string = string;
    
    self.titleLabel.text = string;
}

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithReuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
    }
    return self;
}


- (void)setupUI{
    
    UIView * backView = [UIView new];
    
    backView.backgroundColor = ZRWhiteColor;
    backView.layer.cornerRadius = 5 * SCREENH6;
    backView.layer.masksToBounds = YES;
    
    self.backView = backView;
    
    [self addSubview:self.backView];
    
    UIView * redView = [UIView new];
    
    redView.backgroundColor = ColorWithRGB(0xF44336);
    
    self.redView = redView;
    
    [self.backView  addSubview:self.redView];
    
    
    UILabel * titleLabel = [UILabel new];
    
    titleLabel.text = @"全部评论";
    titleLabel.font = [UIFont boldSystemFontOfSize:15 * SCREENH6];
    titleLabel.textColor = ZRBlackColor;
    
    self.titleLabel = titleLabel;
    
    [self.backView  addSubview:self.titleLabel];
    
    
    UIView * lineView = [UIView new];
    
    lineView.backgroundColor = ColorWithRGB(0xe4e4e4);
    
    self.lineView = lineView;
    
    [self.backView  addSubview:self.lineView];
}


- (void)layoutSubviews{
    
    [self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self).offset(15 * SCREENH6);
        make.trailing.mas_equalTo(self).offset(-15 * SCREENH6);
        make.top.bottom.mas_equalTo(self);
    }];
    
    [self.redView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.backView);
        make.leading.mas_equalTo(self.backView).offset(10 * SCREENH6);
        make.height.mas_equalTo(15 * SCREENH6);
        make.width.mas_equalTo(3 * SCREENH6);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.redView);
        make.leading.mas_equalTo(self.redView.mas_trailing).offset(5 * SCREENH6);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.backView);
        make.leading.mas_equalTo(self.backView).offset(10 * SCREENH6);
        make.trailing.mas_equalTo(self.backView).offset(-10 * SCREENH6);
        make.height.mas_equalTo(1 * SCREENH6);
    }];
}

@end
